import java.util.Timer;
import java.util.TimerTask;

/**
 * 定时器
 */
public class TimerExample {

    public static void main(String[] args) {
        Timer timer = new Timer();

        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("6:30, 该起床了~");
            }
        }, 1000);

        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("7:00, 晨跑~");
            }
        }, 2000);

        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("8:00, 剩下的时间该学习了吧~");
            }
        }, 3000);
    }
}
